using System;
using System.Data;
using System.Data.SqlClient;
using NNS.Framework;
using QLTB.BusinessObjects;

namespace QLTB.DataAccess
{
    /// <summary>
    /// Project: NNS System 
    /// Generated Class for Table : TBL_Thongtin.
    /// Date: 6/29/2010
    /// Author: Trần Hoàng Tâm
    /// </summary>
    public class TBL_ThongtinDA : Object
    {
        #region Get

        public TBL_Thongtin Get()
        {
            TBL_Thongtin obj = null;
            SqlDataReader myReader = (SqlDataReader) SqlHelper.Helper.ExecuteReader(CommandType.Text, "Select * from TBL_Thongtin");
            if (myReader == null)
            {
                SqlHelper.Helper.Close();
                return null;
            }
            if (myReader.Read())
            {
                obj = Populate(myReader);
            }

            myReader.Close();
            myReader.Dispose();
            SqlHelper.Helper.Close();
            return obj;
        }

        #endregion

        public TBL_Thongtin Populate(
            IDataReader myReader)
        {
            TBL_Thongtin obj = null;

            if (myReader != null)
            {
                obj = new TBL_Thongtin();
                if (!myReader.IsDBNull(myReader.GetOrdinal("ID")))
                {
                    obj.ID = (int) myReader["ID"];
                }
                if (!myReader.IsDBNull(myReader.GetOrdinal("DbVersion")))
                {
                    obj.DbVersion = Convert.ToDouble(myReader["DbVersion"]);
                }
                if (!myReader.IsDBNull(myReader.GetOrdinal("AppVersion")))
                {
                    obj.AppVersion = Convert.ToDouble(myReader["AppVersion"]);
                }
            }
            return obj;
        }
    }
}